// 引入公共 scss
import Router from 'vue-router';
import Index from './Index.vue';
import router from './router/index';
import store from './store';
import { Vue } from "vue-property-decorator";
import Vant from 'vant';
import 'vant/lib/index.css';

import '@babel/polyfill';

Vue.use(Vant);

Vue.use(Router);

// 跳转之前
router.beforeEach((to, from, next) => {
  if(document.documentElement.clientHeight < window.innerHeight) document.documentElement.style.height = window.innerHeight + 'px';
  if(to.name == 'Login' || store.state.userInfo.token){ next(); } 
  else {
    // store.commit('getUserInfo');
    if(store.state.userInfo.token){ next(); }
    else{ next('Login'); }
  }
})

Vue.config.productionTip = false;

export default new Vue({ router, store, render: h => h(Index) }).$mount('#content');
 